package com.ytkj.digitalConstruction;

import org.springframework.stereotype.Component;

/**
 * API统一返回对象
 * 
 * @author klaus
 *
 */
/**
 * @author
 * @E-mail:
 * @date 创建时间：2017年12月4日 上午11:55:01
 * @version 1.0
 * @see {@link HttpResult}
 */
@Component
public class ReturnCode {
	
	/**
	 * 是否成功
	 */
	private boolean success;
	
	/**
	 * 消息
	 */
	private String msg;
	
	/**
	 * 对象
	 */
	private Object obj;

	private ReturnCode() {
		this.success = true;
		this.msg = "成功";
	}

	public boolean getSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getObj() {
		return obj;
	}

	public void setObj(Object obj) {
		this.obj = obj;
	}

	@Override
	public String toString() {
		return "ReturnCode [success=" + success + ", msg=" + msg + ", obj=" + obj + "]";
	}

	/**
	 * @author yf 建造者摸模式处理返回数据
	 * @E-mail:
	 * @date 创建时间：2017年12月4日 上午11:55:03
	 * @version 1.0
	 */
	public static class Builder {
		private ReturnCode returnCode;

		public Builder() {
			returnCode = new ReturnCode();
		}

		public Builder Success(boolean bool) {
			returnCode.setSuccess(bool);
			return this;
		}

		public Builder Msg(String msg) {
			returnCode.setMsg(msg);
			return this;
		}

		public Builder Object(Object obj) {
			returnCode.setObj(obj);
			return this;
		}

		public ReturnCode build() {
			return returnCode;
		}
	}

}
